#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int p, sum, q, b;
	int n, m, w;
	scanf("%d %d", &m, &n);
	p = m / n;
	q = m % n;
	b = p + q;
	sum = p;
	while (b/n!=0)
	{
		p = b / n;
		q = b % n;
		b = p + q;
		sum += p;
	}
	w = m + sum;
	printf("%d", w);
	return 0;
}